package com.xja.controller;

import com.xja.common.JsonBean;
import com.xja.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @author CHENCHEN
 * @company 北京学佳澳教育科技
 * @create 2024-01-15 14:16
 */
@RestController
public class IndexController {

    @Autowired
    private IndexService indexService;

    @PostMapping("login")
    public JsonBean login(HttpSession session, String username, String password){
        /**
         * TODO：
         *      1、调用service传入登录名和密码
         *      2、根据用户名查询出对象信息
         *      3、如果查询信息不为null
         *      4、取出接收到的密码+盐再次进行MD5
         *      5、将MD5后的前端密码与数据库中的密码进行eq
         */
        indexService.login(username, password, session);
        return new JsonBean(0, "ok", null);
    }

    @GetMapping("getFirstMenu")
    public JsonBean getFirstMenu(HttpSession session){
        return new JsonBean(0, "ok", session.getAttribute("firstMenu"));
    }

    @GetMapping("getNextMenu")
    public JsonBean getNextMenu(HttpSession session){
        return new JsonBean(0, "ok", session.getAttribute("nextMenu"));
    }

    @PostMapping("logout")
    public JsonBean logout(HttpSession session){

        return null;
    }

    @PostMapping("test")
    public JsonBean test(HttpSession session){

        return null;
    }
}
